﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QuanLyQuangCao
{
    public partial class frmQC_1 : Form
    {
        public frmQC_1()
        {
            InitializeComponent();
            setdata();
        }
        private DataSet ds = new DataSet();
        private void setdata()
        {
            string sql = "select nv.Ma_Nhan_Vien,nv.Ten_Nhan_Vien,sum(dkqc.Gia_Mot_Ky*dkqc.So_Ky_Dang) 'Doanh So' from NhanVien nv inner join DangKyQuangCao dkqc on nv.Ma_Nhan_Vien=dkqc.Ma_Nhan_Vien group by nv.Ma_Nhan_Vien,nv.Ten_Nhan_Vien";
            frmChinh.me.cn1.laydulieu(sql, frmChinh.me.sqlcon, ds, "dangkyquangcao");
             sql = "select ma_nhan_vien,ten_nhan_vien from nhanvien";
            frmChinh.me.cn1.laydulieu(sql, frmChinh.me.sqlcon, ds, "nhanvien");
            DataRelation dr = new DataRelation("nv_dkqc", ds.Tables["nhanvien"].Columns["ma_nhan_vien"], ds.Tables["dangkyquangcao"].Columns["ma_nhan_vien"]);
            ds.Relations.Add(dr);
            comboBox1.DataSource = ds;
            comboBox1.DisplayMember = "nhanvien.ten_nhan_vien";
            comboBox1.ValueMember = "nhanvien.ma_nhan_vien";
            dataGridView1.DataSource = ds;
            dataGridView1.DataMember = "nhanvien.nv_dkqc";
        }
        private void button1_Click(object sender, EventArgs e)
        {
            frmQC_1_rpt fRPT = new frmQC_1_rpt();
            fRPT.fmanv = comboBox1.Text;
        }

        private void frmQC_1_Load(object sender, EventArgs e)
        {

        }
    }
}
